import {message} from "antd"
import axios from "axios";
const instance = axios.create();

// Override timeout default for the library
// Now all requests using this instance will wait 2.5 seconds before timing out
instance.defaults.timeout = 2500;
// Add a request interceptor
instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });

// Add a response interceptor
instance.interceptors.response.use(function (response) {
    // Do something with response data
    message.success("请求成功")
    return response;
  }, function (error) {
     if (error.response.status === "404") {
        message.error("接口没找到")
     } else if (error.response.status === "500") {
        message.error("服务端异常")
     } else if (error.response.status === "502") {
        message.error("接口异常")
     } else {
         message.error("未知错误")
     }
      

    // Do something with response error
    return Promise.reject(error);
  });
export default instance
